my $file = $ARGV[0];

@rr = split(/\//, $file);

print "file $rr[0],$rr[1],$rr[2]\n";

open Input, "<$file" or die"cannot open $file\n";
open Output, ">..\/tmp\/$rr[2]" or die "cannot open ..\/tmp\/$rr[2]\n";
$number = 0;
$firstline = 1;
$start = 0;
$end = 0;
while(<Input>){
	chomp;
	@rs = split;
	
	if($firstline==1){
		$firstline++;
		next;
	}	
	if($firstline==2) {
		$start = $rs[1];
		$firstline++;
		next;
	}
	if($firstline==3){
		$end = $rs[1];
		$firstline++;
		print Output "$start \t $end\n";
		next;
	}
	if($rs[0]>=127) {
		$rs[0] = $rs[0] - 256 -45;
	}
	else {
		$rs[0] = $rs[0] -45;
	}
	if($rs[1]>=127) {
		$rs[1] = $rs[1] - 256 -45;
	}
	else {
		$rs[1] = $rs[1] -45;
	}
	print Output "$number $rs[0]\n";
	$number++;
	print Output "$number $rs[1]\n";
	$number++;
}

close Input;
close Output;
